﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.effects.Particle {
    import flash.display.*;
    import flash.geom.*;
    import Classes.*;

    public class PixieDustEffect extends ParticleEffect {

        private static const EFFECT_NAME:String = "pixieDust";

        protected const TARGET_SPEED_THRESHOLD:Number = 300;

        protected var m_previousTargetPos:Point;

        public function PixieDustEffect(_arg1:MapResource){
            super(_arg1, EFFECT_NAME);
            this.m_previousTargetPos = new Point();
            minVel = 0;
            maxVel = 100;
            minAngle = 0;
            maxAngle = 360;
            minDuration = 0.5;
            maxDuration = 1;
            minRotationVel = -500;
            maxRotationVel = 500;
            minStartScale = 0.5;
            maxStartScale = 1.5;
            endScale = 0;
            startAlpha = 100;
            endAlpha = 0;
            initRotRandomness = 360;
            m_particleContainer.scaleX = 0.5;
            m_particleContainer.scaleY = 0.5;
        }
        override protected function spawnNewParticles(_arg1:Number):void{
            super.spawnNewParticles(_arg1);
            var _local2:DisplayObject = m_mapResource.displayObject;
            if (m_isActive){
                this.m_previousTargetPos.x = _local2.x;
                this.m_previousTargetPos.y = _local2.y;
            };
        }
        override protected function getNumNewParticles(_arg1:Number):int{
            var _local2:DisplayObject = m_mapResource.displayObject;
            var _local3:Number = 0;
            if (((!((this.m_previousTargetPos.x == _local2.x))) || (!((this.m_previousTargetPos.y == _local2.y))))){
                if (Math.sqrt((Math.pow((this.m_previousTargetPos.x - _local2.x), 2) + Math.pow((this.m_previousTargetPos.y - _local2.y), 2))) > this.TARGET_SPEED_THRESHOLD){
                    _local3 = (1 + Math.floor((2 * Math.random())));
                } else {
                    _local3 = Math.floor((1.5 * Math.random()));
                };
            };
            return (_local3);
        }
        override public function animate(_arg1:uint):Boolean{
            var _local2:DisplayObject = m_mapResource.displayObject;
            if (_local2.scaleX == 1){
                m_particleContainer.scaleX = 0.125;
                m_particleContainer.scaleY = 0.125;
            };
            return (super.animate(_arg1));
        }

    }
}//package Classes.effects.Particle 
